﻿#include "hzpch.h"
#include "SourceCode/Base/Input.h"
#include "SourceCode/Base/Application.h"

#include <GLFW/glfw3.h>

namespace Hazal
{
	bool CInput::IsKeyPressed(int nKeyCode)
	{
		GLFWwindow* pWindow = (GLFWwindow*)CApplication::Instance().GetWindow().GetNativeWindow();

		return GLFW_PRESS == glfwGetKey(pWindow, nKeyCode);
	}

	bool CInput::IsMouseButtonPressed(int nButton)
	{
		GLFWwindow* pWindow = (GLFWwindow*)CApplication::Instance().GetWindow().GetNativeWindow();

		return GLFW_PRESS == glfwGetMouseButton(pWindow, nButton);
	}

	float CInput::GetMouseX()
	{
		return CInput::GetMousePosition().first;
	}

	float CInput::GetMouseY()
	{
		return CInput::GetMousePosition().second;
	}

	std::pair<float, float> CInput::GetMousePosition()
	{
		GLFWwindow* pWindow = (GLFWwindow*)CApplication::Instance().GetWindow().GetNativeWindow();
		double dPosX = 0.0, dPosY = 0.0;

		glfwGetCursorPos(pWindow, &dPosX, &dPosY);

		return {dPosX, dPosY};
	}
}